/*
 *  masslink.h
 *  EPPI-0.0
 *
 *  Created by Juan Carlos Garcia Orden on 06/08/2012
 *
 */

#ifndef _masslink_h_
#define _masslink_h_

#include "component.h"
#include "commonutil.h"
#include "MATERIALS/material.h"


using namespace std;

class MassLink : public Component
{
public:
	double initialDis;
	double mass;
	double areaIni;					/** Initial area of the section */
	/** Material name */
	Material* material;				/** Material */
	double partial_qddotOld;
/*	Data members from the base class Component
	int dim;
	int numDofs;
	vector<string> pointNames;
	map<string,Point*,less<string> > mPoints;
	vector<int> localGlob;
	double time;
	string matName;		
	vector<double> q;
	vector<double> dq;
	vector<double> qC;
	vector<double> dqC;
	vector<double> Fi;
	vector<double> Fq;
	vector<double> Ft;
	vector< vector<double> > Ki;
	vector< vector<double> > Kq;
	vector< vector<double> > Kdq;
	vector< vector<double> > M;		// Local contribution to the mass matrix
	double perturbation;	//For numerical differentiation
	int integratorType;
	double thetab;			// Ambient temperature 
*/

public:
	MassLink();
	MassLink(vector<string>&, double, string&, int);
	MassLink(vector<string>&, double, int);
	~MassLink(){}

	/** Virtual functions from base */
	void setDofs(void);
	void initializeGlobalDofs(vector<double> &, vector<double> &, const double &);
	void calcFi(const vector<double>&);
	void calcFq(const int&);
	void calcFt(const double&, const double&, const int&);
	void calcKi(double&);
	void calcKq(int);
	void calcKdq(double&);
	void calcM(const vector<double>&, const double &);
	void calcMLumped(const vector<double>&, const double &);
	void setMatAtComp(Material*);
	string getMatName()	{return matName;}
	void initializeCompRes(const bool&, const double&, const int&, const bool);
//	void initializeCompTang(const bool&, const bool&);
	void initializeCompTang(const bool&);
	void calcEner(double&, double&, double&, double&, double&, double&, double&, int&, vector<double>&, vector<double>&);
	void calcEntropy(double&, double&);
	void calcAM(vector<double>&, vector<double>&, vector<double>&);
	void updateComp(void);
	void setInitialConditions(vector<double>&, vector<double>&){}
	double getTemperature(void){};
	void setIniDofs(vector<double>&);
	void calcPhi(const vector<double>&);
	void calcDPhi(const vector<double>&);
	void calcMSmooth(const vector<double>&, const double&);
	void calcFSmooth(const vector<double>&, const vector<double>&, const double&);
	int checkState(void);
	
	/** Local functions */

	/** Friend functions */
	friend double lTwoNorm(const vector<double>& v1);
	friend double lTwoNorm(const vector<double>& v1, const vector<double>& v2);
	friend void uVersor(const vector<double>& v1, const double & dis, const int& dim, vector<double>& u);
//	friend void uVersor(const vector<double>& v1, const vector<double>& v2, const double & dis, vector<double>& u);
	friend void printSTLVector(vector<double>& v);
	friend void printSTLMatrix(const vector< vector<double> >& m);


};

#endif

